<template>
	<view>
		<view class="cu-custom" :style="[{ height: CustomBar + 'px' }]">
			<view class="cu-bar fixed bg-white"
				:style="[{ height: CustomBar + 'px', paddingTop: StatusBar + 'px' ,borderBottom:'1rpx solid #eee'}]">
				<view class="action"></view>
				<view class="content" :style="[{ top: StatusBar + 'px' }]">
					聚星俱乐部
				</view>
			</view>
		</view>
		<view class="flex align-center justify-between flex-wrap padding-lr-sm">
			<block v-for="(item, index) in lists" :key="index">
				<fu-goods-block :info="item"></fu-goods-block>
			</block>
		</view>
		<uni-load-more :status="status" v-if="lists.length > 5" ></uni-load-more>
		<view class="text-center margin-top" v-if="lists.length == 0">
			<image src="/static/empty/order.png" mode="" style="width: 320rpx;height: 320rpx;"></image>
			<view class="text-999">暂无商品</view>
		</view>
	</view>
</template>

<script>
	import FuGoodsBlock from '../../../components/fu-goods-block/fu-goods-block.vue';

	export default {
		components: {
			FuGoodsBlock,
		},
		data() {
			return {
				page: 1,
				lists: [],
				status: 'more',
			}
		},
		onLoad() {
			this.loadData()
		},
		onPullDownRefresh() {
			
		},
		onReachBottom() {
			this.loadData()
		},
		methods: {
			loadData() {
				if (this.status != 'more') return;
				this.status = 'loading';
				this.$api
					.post(global.apiUrls.getGoodsGetGoodsList, {
						page: this.page,
						is_vip: 1
					})
					.then(res => {
						console.log('俱乐部商品', res);
						if (res.data.code == 1) {
							let total = res.data.data.total;
							let list = res.data.data.data;
							if (this.page == 1) this.lists = [];
							this.lists.push(...list);
							if (this.lists.length >= total) {
								this.status = 'noMore';
							} else {
								this.status = 'more';
								this.page++;
							}
							uni.stopPullDownRefresh();
						} else {
							this.status = 'more';
							uni.stopPullDownRefresh();
						}
					})
					.catch(err => {
						uni.stopPullDownRefresh();
					});
			},
		}
	}
</script>

<style lang="scss">

</style>